<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>datagrid</title>
<link rel="stylesheet" type="text/css" href="css/easyui.css" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/SyntaxHighlighter.css" />

<script type="text/javascript" src="js/shCore.js"></script>
<script type="text/javascript" src="js/shBrushJScript.js"></script>
<script type="text/javascript" src="js/shBrushXml.js"></script>
<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
</head>
<body style="text-align:left">
<div style="padding:10px">

<h3>DataGrid</h3>
<p>Extend from $.fn.panel.defaults. Override defaults with $.fn.datagrid.defaults.</p>

<h4>Dependencies</h4>
<ul>
	<li>panel</li>
	<li>resizable</li>
	<li>linkbutton</li>
	<li>pagination</li>
</ul>

<h4>Usage</h4>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-xml"><li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">table</span><span>&nbsp;</span><span class="attribute">id</span><span>=</span><span class="attribute-value">"tt"</span><span class="tag">&gt;</span><span class="tag">&lt;/</span><span class="tag-name">table</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li></ol></div><textarea class="html" name="code-datagrid" style="display: none;">	&lt;table id="tt"&gt;&lt;/table&gt;
</textarea>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-c"><li class="alt"><span><span>$(</span><span class="string">'#tt'</span><span>).datagrid({&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;url:<span class="string">'datagrid_data.json'</span><span>,&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;columns:[[&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{field:<span class="string">'code'</span><span>,title:</span><span class="string">'Code'</span><span>,width:100},&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{field:<span class="string">'name'</span><span>,title:</span><span class="string">'Name'</span><span>,width:100},&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{field:<span class="string">'price'</span><span>,title:</span><span class="string">'Price'</span><span>,width:100,align:</span><span class="string">'right'</span><span>}&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;]]&nbsp;&nbsp;</span></li><li class=""><span>});&nbsp;&nbsp;</span></li></ol></div><textarea class="js" name="code-datagrid" style="display: none;">	$('#tt').datagrid({
		url:'datagrid_data.json',
		columns:[[
			{field:'code',title:'Code',width:100},
			{field:'name',title:'Name',width:100},
			{field:'price',title:'Price',width:100,align:'right'}
		]]
	});
</textarea>

<h4>DataGrid Properties</h4>
<p>The properties extend from panel. below is the added properties for datagrid.</p>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Type</strong></th>
<th><strong>Description</strong></th>

<th><strong>Default</strong></th>
</tr>
<tr>
<td>columns</td>
<td>array</td>
<td>The datagrid columns config object, see column properties for more details.</td>
<td>undefined</td>
</tr>
<tr>
<td>frozenColumns</td>
<td>array</td>

<td>Same as the columns property, but the these columns will be frozen on left.</td>
<td>undefined</td>
</tr>
<tr>
<td>fitColumns</td>
<td>boolean</td>
<td>True to auto expand/contract the size of the columns to fit the grid width and prevent horizontal scrolling.</td>
<td>false</td>
</tr>
<tr>
<td>autoRowHeight</td>
<td>boolean</td>
<td>
Defines if set the row height based on the contents of that row.
Set to false can improve loading performance.
</td>
<td>true</td>
</tr>
<tr>
<td>striped</td>

<td>boolean</td>
<td>True to stripe the rows.</td>
<td>false</td>
</tr>
<tr>
<td>method</td>
<td>string</td>
<td>The method type to request remote data.</td>
<td>post</td>
</tr>

<tr>
<td>nowrap</td>
<td>boolean</td>
<td>
True to display data in one line.
Set to true can improve loading performance.
</td>
<td>true</td>
</tr>
<tr>
<td>idField</td>
<td>string</td>
<td>Indicate which field is an identity field.</td>

<td>null</td>
</tr>
<tr>
<td>url</td>
<td>string</td>
<td>A URL to request data from remote site.</td>
<td>null</td>
</tr>
<tr>
<td>loadMsg</td>
<td>string</td>

<td>When loading data from remote site, show a prompt message.</td>
<td>Processing, please wait ��</td>
</tr>
<tr>
<td>pagination</td>
<td>boolean</td>
<td>True to show a pagination toolbar on datagrid bottom.</td>
<td>false</td>
</tr>
<tr>
<td>rownumbers</td>

<td>boolean</td>
<td>True to show a row number column.</td>
<td>false</td>
</tr>
<tr>
<td>singleSelect</td>
<td>boolean</td>
<td>True to allow selecting only one row.</td>
<td>false</td>
</tr>

<tr>
<td>pageNumber</td>
<td>number</td>
<td>When set pagination property, initialize the page number.</td>
<td>1</td>
</tr>
<tr>
<td>pageSize</td>
<td>number</td>
<td>When set pagination property, initialize the page size.</td>

<td>10</td>
</tr>
<tr>
<td>pageList</td>
<td>array</td>
<td>When set pagination property, initialize the page size selecting list.</td>
<td>[10,20,30,40,50]</td>
</tr>
<tr>
<td>queryParams</td>
<td>object</td>

<td>When request remote data, sending additional parameters also.</td>
<td>{}</td>
</tr>
<tr>
<td>sortName</td>
<td>string</td>
<td>Defines which column can be sorted.</td>
<td>null</td>
</tr>
<tr>
<td>sortOrder</td>

<td>string</td>
<td>Defines the column sort order, can only be 'asc' or 'desc'.</td>
<td>asc</td>
</tr>
<tr>
<td>remoteSort</td>
<td>boolean</td>
<td>Defines if to sort data from server.</td>
<td>true</td>
</tr>

<tr>
<td>showFooter</td>
<td>boolean</td>
<td>Defines if to show row footer.</td>
<td>false</td>
</tr>
<tr>
<td>rowStyler</td>
<td>function</td>
<td>Return style such as 'background:red'. The function take two parameter:<br>

rowIndex: the row index, start with 0<br>
rowData: the record corresponding to this row</td>
<td></td>
</tr>
<tr>
<td>loader</td>
<td>function(param,success,error)</td>
<td>
Defines how to load data from remote server. Return false can abort this action.
This function takes following parameters:<br>
param: the parameter object to pass to remote server.<br>
success(data): the callback function that will be called when retrieve data successfully.<br>
error(): the callback function that will be called when failed to retrieve data.
</td>
<td>json loader</td>
</tr>
<tr>
<td>loadFilter</td>
<td>function</td>
<td>Return the filtered data to display. The function take one parameter 'data' that indicate the original data. You can change original source data to standard data format. This function must return standard data object that contain 'total' and 'rows' properties.</td>
<td></td>
</tr>
<tr>
<td>editors</td>

<td>object</td>
<td>Defines the editor when editing a row.</td>
<td>predefined editors</td>
</tr>
<tr>
<td>view</td>
<td>object</td>
<td>Defines the view of datagrid.</td>
<td>default view</td>
</tr>

</tbody></table>

<h4>Column Properties</h4>
<p>The DataGrid Columns is an array object, which element is an array too.
The element of element array is a config object, which defines every column field.</p><p>
</p><p>code example:</p>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-c"><li class="alt"><span><span>columns:[[&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;{field:<span class="string">'itemid'</span><span>,title:</span><span class="string">'Item&nbsp;ID'</span><span>,rowspan:2,width:80,sortable:</span><span class="keyword">true</span><span>},&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;{field:<span class="string">'productid'</span><span>,title:</span><span class="string">'Product&nbsp;ID'</span><span>,rowspan:2,width:80,sortable:</span><span class="keyword">true</span><span>},&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;{title:<span class="string">'Item&nbsp;Details'</span><span>,colspan:4}&nbsp;&nbsp;</span></span></li><li class="alt"><span>],[&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;{field:<span class="string">'listprice'</span><span>,title:</span><span class="string">'List&nbsp;Price'</span><span>,width:80,align:</span><span class="string">'right'</span><span>,sortable:</span><span class="keyword">true</span><span>},&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;{field:<span class="string">'unitcost'</span><span>,title:</span><span class="string">'Unit&nbsp;Cost'</span><span>,width:80,align:</span><span class="string">'right'</span><span>,sortable:</span><span class="keyword">true</span><span>},&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;{field:<span class="string">'attr1'</span><span>,title:</span><span class="string">'Attribute'</span><span>,width:100},&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;{field:<span class="string">'status'</span><span>,title:</span><span class="string">'Status'</span><span>,width:60}&nbsp;&nbsp;</span></span></li><li class=""><span>]]&nbsp;&nbsp;</span></li></ol></div><textarea class="js" name="code-datagrid" style="display: none;">	columns:[[
		{field:'itemid',title:'Item ID',rowspan:2,width:80,sortable:true},
		{field:'productid',title:'Product ID',rowspan:2,width:80,sortable:true},
		{title:'Item Details',colspan:4}
	],[
		{field:'listprice',title:'List Price',width:80,align:'right',sortable:true},
		{field:'unitcost',title:'Unit Cost',width:80,align:'right',sortable:true},
		{field:'attr1',title:'Attribute',width:100},
		{field:'status',title:'Status',width:60}
	]]
</textarea>
<p></p>

<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Type</strong></th>
<th><strong>Description</strong></th>
<th><strong>Default</strong></th>

</tr>
<tr>
<td>title</td>
<td>string</td>
<td>The column title text.</td>
<td>undefined</td>
</tr>
<tr>
<td>field</td>
<td>string</td>
<td>The column field name.</td>

<td>undefined</td>
</tr>
<tr>
<td>width</td>
<td>number</td>
<td>The width of column.</td>
<td>undefined</td>
</tr>
<tr>
<td>rowspan</td>
<td>number</td>

<td>Indicate how many rows a cell should take up.</td>
<td>undefined</td>
</tr>
<tr>
<td>colspan</td>
<td>number</td>
<td>Indicate how many columns a cell should take up.</td>
<td>undefined</td>
</tr>
<tr>
<td>align</td>

<td>string</td>
<td>Indicate how to align the column data. 'left','right','center' can be used.</td>
<td>undefined</td>
</tr>
<tr>
<td>sortable</td>
<td>boolean</td>
<td>True to allow the column can be sorted.</td>
<td>undefined</td>
</tr>

<tr>
<td>resizable</td>
<td>boolean</td>
<td>True to allow the column can be resized.</td>
<td>undefined</td>
</tr>
<tr>
<td>hidden</td>
<td>boolean</td>
<td>True to hide the column.</td>

<td>undefined</td>
</tr>
<tr>
<td>checkbox</td>
<td>boolean</td>
<td>True to show a checkbox.</td>
<td>undefined</td>
</tr>
<tr>
<td>formatter</td>
<td>function</td>

<td>The cell formatter function, take three parameter:<br>
value: the field value.<br>
rowData: the row record data.<br>
rowIndex: the row index.</td>
<td>undefined</td>
</tr>
<tr>
<td>styler</td>
<td>function</td>
<td>The cell styler function, return style string to custom the cell style such as 'background:red'. The function take three parameter:<br>

value: the field value.<br>
rowData: the row record data.<br>
rowIndex: the row index.</td>
<td>undefined</td>
</tr>
<tr>
<td>sorter</td>
<td>function</td>
<td>The custom field sort function, take two parameters:<br>
a: the first field value.<br>

b: the second field value.</td>
<td>undefined</td>
</tr>
<tr>
<td>editor</td>
<td>string,object</td>
<td>Indicate the edit type. When string indicates the edit type, when object contains two properties:<br>
type: string, the edit type, possible type is: text,textarea,checkbox,numberbox,validatebox,datebox,combobox,combotree.<br>
options: object, the editor options corresponding to the edit type.</td>
<td>undefined</td>

</tr>
</tbody></table>

<h4>Editor</h4>
<p>Override defaults with $.fn.datagrid.defaults.editors.</p><p>
</p><p>Every editor has following actions:</p>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>

<th><strong>Parameters</strong></th>
<th><strong>Description</strong></th>
</tr>
<tr>
<td>init</td>
<td>container, options</td>
<td>Initialize the editor and return the target object.</td>
</tr>
<tr>
<td>destroy</td>
<td>target</td>

<td>Destroy the editor if necessary.</td>
</tr>
<tr>
<td>getValue</td>
<td>target</td>
<td>Get value from editor text.</td>
</tr>
<tr>
<td>setValue</td>
<td>target , value</td>
<td>Set value for editor.</td>

</tr>
<tr>
<td>resize</td>
<td>target , width</td>
<td>Resize the editor if necessary.</td>
</tr>
</tbody></table>

<p>For example, the text editor is defined as following:</p>
<div class="dp-highlighter"><div class="bar"><div class="tools"></div></div><ol start="1" class="dp-c"><li class="alt"><span><span>$.extend($.fn.datagrid.defaults.editors,&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;text:&nbsp;{&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;init:&nbsp;<span class="keyword">function</span><span>(container,&nbsp;options){&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">var</span><span>&nbsp;input&nbsp;=&nbsp;$(</span><span class="string">'&lt;input&nbsp;type="text"&nbsp;class="datagrid-editable-input"&gt;'</span><span>).appendTo(container);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;input;&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getValue:&nbsp;<span class="keyword">function</span><span>(target){&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;$(target).val();&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setValue:&nbsp;<span class="keyword">function</span><span>(target,&nbsp;value){&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(target).val(value);&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resize:&nbsp;<span class="keyword">function</span><span>(target,&nbsp;width){&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">var</span><span>&nbsp;input&nbsp;=&nbsp;$(target);&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;($.boxModel&nbsp;==&nbsp;</span><span class="keyword">true</span><span>){&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input.width(width&nbsp;-&nbsp;(input.outerWidth()&nbsp;-&nbsp;input.width()));&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">else</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;input.width(width);&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li><li class=""><span>});&nbsp;&nbsp;</span></li></ol></div><textarea class="js" name="code-datagrid" style="display: none;">	$.extend($.fn.datagrid.defaults.editors, {
		text: {
			init: function(container, options){
				var input = $('&lt;input type="text" class="datagrid-editable-input"&gt;').appendTo(container);
				return input;
			},
			getValue: function(target){
				return $(target).val();
			},
			setValue: function(target, value){
				$(target).val(value);
			},
			resize: function(target, width){
				var input = $(target);
				if ($.boxModel == true){
					input.width(width - (input.outerWidth() - input.width()));
				} else {
					input.width(width);
				}
			}
		}
	});
</textarea>

<h4>DataGrid View</h4>
<p>Override defaults with $.fn.datagrid.defaults.view.</p>
<p>The view is an object that will tell datagrid how to render rows. The object must defines the following functions:</p>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Parameters</strong></th>

<th><strong>Description</strong></th>
</tr>
<tr>
<td>render</td>
<td>target, container, frozen</td>
<td>Called when the data is loaded.<br>
target: DOM object, the datagrid object.<br>
container: the rows container.<br>
frozen: indicate if to render the frozen container.</td>
</tr>

<tr>
<td>renderFooter</td>
<td>target, container, frozen</td>
<td>This is an option function to render row footer.</td>
</tr>
<tr>
<td>renderRow</td>
<td>target, fields, frozen, rowIndex, rowData</td>
<td>This is an option function and will be called by render function.</td>
</tr>
<tr>

<td>refreshRow</td>
<td>target, rowIndex</td>
<td>Defines how to refresh the specified row.</td>
</tr>
<tr>
<td>onBeforeRender</td>
<td>target, rows</td>
<td>Fires before the view is rendered.</td>
</tr>
<tr>
<td>onAfterRender</td>

<td>target</td>
<td>Fires after the view is rendered.</td>
</tr>
</tbody></table>

<h4>Events</h4>
<p>The events extend from panel, below is the added events for datagrid.</p>
<table class="doc-table">

<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Parameters</strong></th>
<th><strong>Description</strong></th>
</tr>
<tr>
<td>onLoadSuccess</td>
<td>data</td>
<td>Fires when data is loaded successfully.</td>
</tr>
<tr>

<td>onLoadError</td>
<td>none</td>
<td>Fires when some error occur to load remote data.</td>
</tr>
<tr>
<td>onBeforeLoad</td>
<td>param</td>
<td>Fires before a request is made to load data. If return false the load action will be canceled.</td>
</tr>
<tr>
<td>onClickRow</td>

<td>rowIndex, rowData</td>
<td>Fires when user click a row, the parameters contains:<br>
rowIndex: the clicked row index, start with 0<br>
rowData: the record corresponding to the clicked row</td>
</tr>
<tr>
<td>onDblClickRow</td>
<td>rowIndex, rowData</td>
<td>Fires when user dblclick a row, the parameters contains:<br>
rowIndex: the clicked row index, start with 0<br>

rowData: the record corresponding to the clicked row</td>
</tr>
<tr>
<td>onClickCell</td>
<td>rowIndex, field, value</td>
<td>Fires when user click a cell.</td>
</tr>
<tr>
<td>onDblClickCell</td>
<td>rowIndex, field, value</td>
<td>Fires when user dblclick a cell.</td>

</tr>
<tr>
<td>onSortColumn</td>
<td>sort, order</td>
<td>Fires when user sort a column, the parameters contains:<br>
sort: the sort column field name<br>
order: the sort column order</td>
</tr>
<tr>
<td>onResizeColumn</td>
<td>field, width</td>

<td>Fires when user resize the column.</td>
</tr>
<tr>
<td>onSelect</td>
<td>rowIndex, rowData</td>
<td>Fires when user select a row, the parameters contains:<br>
rowIndex: the selected row index, start with 0<br>
rowData: the record corresponding to the selected row</td>
</tr>
<tr>
<td>onUnselect</td>

<td>rowIndex, rowData</td>
<td>Fires when user unselect a row, the parameters contains:<br>
rowIndex: the unselected row index, start with 0<br>
rowData: the record corresponding to the unselected row</td>
</tr>
<tr>
<td>onSelectAll</td>
<td>rows</td>
<td>Fires when user select all rows.</td>
</tr>

<tr>
<td>onUnselectAll</td>
<td>rows</td>
<td>Fires when user unselect all rows.</td>
</tr>
<tr>
<td>onBeforeEdit</td>
<td>rowIndex, rowData</td>
<td>Fires when user start editing a row, the parameters contains:<br>
rowIndex: the editing row index, start with 0<br>

rowData: the record corresponding to the editing row</td>
</tr>
<tr>
<td>onAfterEdit</td>
<td>rowIndex, rowData, changes</td>
<td>Fires when user finish editing, the parameters contains:<br>
rowIndex: the editing row index, start with 0<br>
rowData: the record corresponding to the editing row<br>
changes: the changed field/value pairs</td>
</tr>

<tr>
<td>onCancelEdit</td>
<td>rowIndex, rowData</td>
<td>Fires when user cancel editing a row, the parameters contains:<br>
rowIndex: the editing row index, start with 0<br>
rowData: the record corresponding to the editing row</td>
</tr>
<tr>
<td>onHeaderContextMenu</td>
<td>e, field</td>

<td>Fires when the header of datagrid is right clicked.</td>
</tr>
<tr>
<td>onRowContextMenu</td>
<td>e, rowIndex, rowData</td>
<td>Fires when a row is right clicked.</td>
</tr>
</tbody></table>

<h4>Methods</h4>
<table class="doc-table">
<tbody><tr>
<th><strong>Name</strong></th>
<th><strong>Parameter</strong></th>
<th><strong>Description</strong></th>
</tr>
<tr>
<td>options</td>
<td>none</td>

<td>Return the options object.</td>
</tr>
<tr>
<td>getPager</td>
<td>none</td>
<td>Return the pager object.</td>
</tr>
<tr>
<td>getPanel</td>
<td>none</td>
<td>Return the panel object.</td>

</tr>
<tr>
<td>getColumnFields</td>
<td>frozen</td>
<td>
Return the column fields. If frozen setted to true the frozen column fields is returned.<br>
Code example:<br>
<pre style="color:#006600">var opts = $('#dg').datagrid('getColumnFields');	// get unfrozen columns
var opts = $('#dg').datagrid('getColumnFields', true); // get frozen columns
</pre>
</td>
</tr>
<tr>
<td>getColumnOption</td>
<td>field</td>
<td>Return the specified column option.</td>
</tr>

<tr>
<td>resize</td>
<td>param</td>
<td>Do resize and do layout.</td>
</tr>
<tr>
<td>load</td>
<td>param</td>
<td>
Load and show the first page rows. If the 'param' is specified, it will replace with the queryParams property.
Usually do a query by passing some parameters, this method can be called to load new data from server.
<pre style="color:#006600">$('#dg').datagrid('load',{
	code: '01',
	name: 'name01'
});
</pre>
</td>
</tr>
<tr>

<td>reload</td>
<td>param</td>
<td>Reload the rows. Same as the 'load' method but stay on current page.</td>
</tr>
<tr>
<td>reloadFooter</td>
<td>footer</td>
<td>
Reload the footer rows. Code examples:
<pre style="color:#006600">// update footer row values and then refresh
var rows = $('#dg').datagrid('getFooterRows');
rows[0]['name'] = 'new name';
rows[0]['salary'] = 60000;
$('#dg').datagrid('reloadFooter');

// update footer rows with new data
$('#dg').datagrid('reloadFooter',[
	{name: 'name1', salary: 60000},
	{name: 'name2', salary: 65000}
]);
</pre>
</td>
</tr>
<tr>
<td>loading</td>

<td>none</td>
<td>Display loading status.</td>
</tr>
<tr>
<td>loaded</td>
<td>none</td>
<td>Hide loading status.</td>
</tr>
<tr>
<td>fitColumns</td>
<td>none</td>

<td>Make columns auto expand/collapse to fit datagrid width.</td>
</tr>
<tr>
<td>fixColumnSize</td>
<td>none</td>
<td>fix columns size.</td>
</tr>
<tr>
<td>fixRowHeight</td>
<td>index</td>
<td>fix the specified row height. If 'index' parameter is not defined, all rows height will be fixed.</td>

</tr>
<tr>
<td>loadData</td>
<td>data</td>
<td>Load local data, the old rows will be removed.</td>
</tr>
<tr>
<td>getData</td>
<td>none</td>
<td>Return the loaded data.</td>
</tr>

<tr>
<td>getRows</td>
<td>none</td>
<td>Return the current page rows.</td>
</tr>
<tr>
<td>getFooterRows</td>
<td>none</td>
<td>Return the footer rows.</td>
</tr>
<tr>

<td>getRowIndex</td>
<td>row</td>
<td>Return the specified row index, the row parameter can be a row record or an id field value.</td>
</tr>
<tr>
<td>getSelected</td>
<td>none</td>
<td>Return the first selected row record or null.</td>
</tr>
<tr>
<td>getSelections</td>

<td>none</td>
<td>Return all selected rows, when no record selected, am empty array will return.</td>
</tr>
<tr>
<td>clearSelections</td>
<td>none</td>
<td>Clear all selections.</td>
</tr>
<tr>
<td>selectAll</td>
<td>none</td>

<td>Select all current page rows.</td>
</tr>
<tr>
<td>unselectAll</td>
<td>none</td>
<td>Unselect all current page rows.</td>
</tr>
<tr>
<td>selectRow</td>
<td>index</td>
<td>Select a row, the row index start with 0.</td>

</tr>
<tr>
<td>selectRecord</td>
<td>idValue</td>
<td>Select a row by passing id value parameter.</td>
</tr>
<tr>
<td>unselectRow</td>
<td>index</td>
<td>Unselect a row.</td>
</tr>

<tr>
<td>beginEdit</td>
<td>index</td>
<td>Begin editing a row.</td>
</tr>
<tr>
<td>endEdit</td>
<td>index</td>
<td>End editing a row.</td>
</tr>
<tr>

<td>cancelEdit</td>
<td>index</td>
<td>Cancel editing a row.</td>
</tr>
<tr>
<td>getEditors</td>
<td>index</td>
<td>Get the specified row editors. Each editor has the following properties:<br>
actions: the actions that the editor can do.<br>
target: the target editor jQuery object.<br>

field: the field name.<br>
type: the editor type.</td>
</tr>
<tr>
<td>getEditor</td>
<td>options</td>
<td>Get the specified editor, the options contains two properties:<br>
index: the row index.<br>
field: the field name.</td>
</tr>

<tr>
<td>refreshRow</td>
<td>index</td>
<td>Refresh a row.</td>
</tr>
<tr>
<td>validateRow</td>
<td>index</td>
<td>validate the specified row, return true when valid.</td>
</tr>
<tr>

<td>updateRow</td>
<td>param</td>
<td>Update the specified row, the param contains following properties:<br>
index: the row index to be updated.<br>
row: the new row data.</td>
</tr>
<tr>
<td>appendRow</td>
<td>row</td>
<td>
Append a new row. The new row will be added to the last position:
<pre style="color:#006600">$('#dg').datagrid('appendRow',{
	name: 'new name',
	age: 30,
	note: 'some messages'
});
</pre>
</td>
</tr>
<tr>
<td>insertRow</td>
<td>param</td>
<td>
Insert a new row, the param contains following properties:<br>
index: the row index to insert into, if not defined, append the new row.<br>
row: the row data. Code examples:
<pre style="color:#006600">// insert a new row at second row position
$('#dg').datagrid('insertRow',{
	index: 1,	// index start with 0
	row: {
		name: 'new name',
		age: 30,
		note: 'some messages'
	}
});
</pre>
</td>
</tr>
<tr>
<td>deleteRow</td>
<td>index</td>

<td>Delete a row.</td>
</tr>
<tr>
<td>getChanges</td>
<td>type</td>
<td>Get changed rows since the last commit. The type parameter indicate which type changed rows, possible value is: inserted,deleted,updated,etc. When the type parameter is not assigned, return all changed rows.</td>
</tr>
<tr>
<td>acceptChanges</td>
<td>none</td>
<td>Commits all the changes data since it was loaded or since the last time acceptChanges was called.</td>

</tr>
<tr>
<td>rejectChanges</td>
<td>none</td>
<td>Rolls back all the changes data since it was created, or since the last time acceptChanges was called.</td>
</tr>
<tr>
<td>mergeCells</td>
<td>options</td>
<td>Merge some cells to one cell, the options contains following properties:<br>
index: the row index.<br>

field: the field name.<br>
rowspan: the rowspan count to be merged.<br>
colspan: the colspan count to be merged.</td>
</tr>
<tr>
<td>showColumn</td>
<td>field</td>
<td>Display the specified column.</td>
</tr>
<tr>
<td>hideColumn</td>

<td>field</td>
<td>Hide the specified column.</td>
</tr>
</tbody></table>

</div>	
</body>
</html>